#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.

FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base
WORKDIR /app
EXPOSE 80

FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
WORKDIR /src
COPY ["Baby.Shop.Web/Baby.ShopService.Host.csproj", "Baby.Shop.Web/"]
COPY ["Baby.Shop.HttpApi/5.Baby.Shop.HttpApi.csproj", "Baby.Shop.HttpApi/"]
COPY ["Baby.Shop.Application.Contracts/3.Baby.Shop.Application.Contracts.csproj", "Baby.Shop.Application.Contracts/"]
COPY ["Baby.Shop.Domain.Shared/0.Baby.Shop.Domain.Shared.csproj", "Baby.Shop.Domain.Shared/"]
COPY ["Baby.Shop.Application/4.Baby.Shop.Application.csproj", "Baby.Shop.Application/"]
COPY ["Baby.Shop.Domain/1.Baby.Shop.Domain.csproj", "Baby.Shop.Domain/"]
COPY ["Baby.Shop.EntityFrameworkCore/2.Baby.Shop.EntityFrameworkCore.csproj", "Baby.Shop.EntityFrameworkCore/"]
COPY ["Baby.Shop.Util/Baby.Shop.Util.csproj", "Baby.Shop.Util/"]
RUN dotnet restore "Baby.Shop.Web/Baby.ShopService.Host.csproj"
COPY . .
WORKDIR "/src/Baby.Shop.Web"
RUN dotnet build "Baby.ShopService.Host.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "Baby.ShopService.Host.csproj" -c Release -o /app/publish

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Baby.ShopService.Host.dll"]